@extends('admin.common.app')
@section('cont')
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>成绩管理
        <span class="c-gray en">&gt;</span>导入成绩
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <article class="cl pd-20">
        @include('admin.common.msg')
        <form action="{{ route('admin.grade.lead') }}" enctype="multipart/form-data" method="post" class="form form-horizontal" id="form-admin-add">
           @csrf
            <div class="row cl">
                {{--考试民初--}}
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>考试信息：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    考试名称：
                    <span class="select-box" style="width:150px;">
                         <select onchange="chg(this);" class="select" id="test_name" name="test_name" size="1">
                             <option value="-1">请选择</option>
                             @foreach($examinfo as $test_name)
                                 <option value="{{$test_name}}" >{{$test_name}}</option>
                             @endforeach
                        </select>
                    </span>
                    班级名称：
                    <span class="select-box" style="width:150px;">
                         <select class="select" id="class_name" name="class_name" size="1">
                               <option value="-1">请选择</option>
                        </select>
                    </span>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>班主任姓名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" autocomplete="off" value="" placeholder="请输入班主任姓名" id="class_teacher" name="class_teacher" autocapitalize="off">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">附件：</label>
                <div class="formControls col-xs-8 col-sm-9"> <span class="btn-upload form-group">
				<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加附件！" style="width:200px">
				<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 浏览文件</a>
				<input type="file" id="file" name="file" class="input-file">
				</span></div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;添加成绩&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
</section>
@endsection
@section('js')
    <script type="text/javascript" src="/admin/webuploader-0.1.5/webuploader.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript">
        function chg(obj) {
            if (obj.value != -1) {
               var test_name=$(obj).val();
               $.ajax({
                   url:"{{route('admin.grade.lead')}}",
                   type:'POST',
                   data:{
                       _token:'{{csrf_token()}}',
                       test_name:test_name,
                   },
                   //成功回调函数
                   success:function(json){
                       if (json.status==0){
                           //获取子元素
                           for (arr of json.class_name) {
                            var list="<option value='"+arr+"'>"+arr+"</option>"
                           }
                           $('#class_name').children('option').after(list);
                       }
                   }
               })
            }
        }
    </script>

@endsection
